﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace HREntities
{
    public abstract class TaxID
    {
        private string id;
        public TaxID(string id)
        {
            ID = id;
        }
        public string ID
        {
            get { return id; }
            set
            {
                if (value != null && Regex.IsMatch(value, ValidationRegex))
                    id = value;
                else
                    throw new ArgumentException("Invalid Tax ID");
            }
        }

        protected abstract string ValidationRegex
        {
            get;
        }

        public override string ToString()
        {
            return ID;
        }
    }

    public class OrganizationTaxId : TaxID
    {
        public OrganizationTaxId(string taxid)
            : base(taxid) { }

        protected override string ValidationRegex
        {
            get { return @"^\d\d-\d{7}$"; }
        }
    }

    public class SSN : TaxID
    {
        public SSN(string ssn) : base(ssn) { }
        protected override string ValidationRegex
        {
            get { return @"^\d{3}-\d\d-\d{4}$"; }
        }
    }
}
